<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Create</title>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
<form class="layui-form layui-form-pane" action="" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">仓库编码</label>
        <div class="layui-input-inline">
            <input type="hidden" id="iID" name="iID" v-model="iID" />
            <input type="text" id="cWhCode" name="cWhCode" required lay-verify="required" placeholder="请输入仓库编码"
                   class="layui-input" v-model="cWhCode">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">仓库姓名</label>
        <div class="layui-input-inline">
            <input type="text" id="cWhName" name="cWhName" required lay-verify="required" placeholder="请输入仓库姓名"
                   class="layui-input" v-model="cWhName">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址</label>
        <div class="layui-input-inline">
            <input type="text" id="cWhAddress" name="cWhAddress" placeholder="请输入地址" autocomplete="off"
                   class="layui-input" v-model="cWhAddress">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="/js/vue.min.js"></script>
<script src="/js/jquery-3.3.1.min.js"></script>
<script src="/js/jquery.validate.min.js"></script>
<script src="/layui/layui.all.js"></script>
<script src="/layui/extend/tableSelect.js"></script>

<script>
    var data=${data};

    var vv=new Vue ({
        el:".layui-form",
        data:data
    });
    var form = layui.form;
    form.render();

    //监听提交
    form.on('submit(formDemo)', function (data) {
        $.ajax({
            type: "POST",
            data: data.field,
            dataTypeString: "json",
            async: false,
            url: "/warehouse/update",
            success: function (msg) {
                console.log(msg);
                if (msg.code == "0") {
                    //当你在iframe页面关闭自身时
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }
            }
        });
        //console.log(data);
        return false;
    });
</script>

</body>
</html>
